package com.mybatis.service.Impl;

import com.mybatis.service.Message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.support.MessageBuilder;

import javax.annotation.Resource;

import org.springframework.cloud.stream.messaging.Source;

import javax.annotation.Resource;
import java.util.UUID;


/**
 * @author cyt
 * @create 2020-05-31 16:10
 */
@EnableBinding(Source.class)
public class MessageImpl implements Message {

    @Autowired
    private MessageChannel output;

    public String send() {
        String substring = UUID.randomUUID().toString().substring(0, 4);
        output.send(MessageBuilder.withPayload(substring).build());
        System.out.println("message **" + substring);

        return null;
    }
}
